//
//  TL_ProductionChapterModel.m
//  WXReader
//
//  Created by Andrew on 2020/3/21.
//  Copyright © 2020 Andrew. All rights reserved.
//

#import "TL_ProductionChapterModel.h"


@implementation TL_ProductionChapterModel

+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
    return @{
             @"image_list" : [TL_ImageListModel class]
             };
}

+ (NSDictionary *)modelCustomPropertyMapper {
    return @{
            @"production_id":@[@"book_id", @"comic_id", @"audio_id"],
            @"relation_production_id":@"relation_book_id",
            @"total_words":@"words",
            @"name" :@[@"name", @"title", @"book_name", @"comic_name", @"audio_name"],
            @"cover":@[@"cover", @"small_cover"],
            @"chapter_id":@"chapterId",
            @"chapter_title":@"chapterName"
             };
}

+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{
        @"chapter_id":@"chapterId",
        @"chapter_title":@"chapterName",
    };
}

- (void)setAuthor_note:(NSString *)author_note {
    _author_note = author_note;
}

+ (nullable instancetype)modelWithDictionary:(NSDictionary *)dictionary {
    TL_ProductionChapterModel *productionModel = [super modelWithDictionary:dictionary];
    for (TL_ImageListModel *image in productionModel.image_list) {
        image.comic_id = productionModel.production_id;
        image.chapter_id = productionModel.chapter_id;
    }
    return productionModel;
}

+ (NSArray *)checkChapterList:(NSArray *)arr{
    
    if (arr) {
        
        for (int i=0;i<arr.count;i++) {
            TL_ProductionChapterModel *model = arr[i];
            model.can_read = YES;
            
            if (model.payNum == 0) {
                
                model.is_vip = YES;
                
            }
            model.display_order = i;
            
        }
        
        return arr;
    }
    
    return nil;
}
@end

@implementation TL_ImageListModel

+ (NSDictionary *)modelCustomPropertyMapper {
    return @{
        @"image_update_time" : @"update_time"
    };
}

- (CGFloat)realWidth {
    if (_realWidth > 0) return _realWidth;
    
    _realWidth = 100;
    
    return _realWidth;
}

- (CGFloat)realHeight {
    if (_realHeight > 0) return _realHeight;
    
    _realHeight = 100;
    
    return _realHeight;
}
@end
